home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / rendRelPanel.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.1 KB  |  331 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17.     
  18. global proc showRendRelPanelMenu(int $show, string $menuBarLayout)
  19. {
  20.   if ($show) {
  21.     menuBarLayout -e -h 25 $menuBarLayout;
  22.   } else {
  23.     menuBarLayout -e -h 1 $menuBarLayout;
  24.   }
  25.   optionVar -intValue showRendRelPanelMenu $show;
  26. }
  27.  
  28. global proc buildRRPeditMenu (string $editorName, string $parentMenu)
  29. {
  30.     setParent -menu $parentMenu;
  31.  
  32.     // These should be unique enough names for the widgets for this
  33.     // instance of the rendering rel. editor
  34.  
  35.     string $addItem            = ($editorName + "addItem");
  36.     string $removeItem         = ($editorName + "removeItem");
  37.     string $createSGitem     = ($editorName + "createSGitem");
  38.  
  39.     // Check to see if we have to build the menu items
  40.  
  41.     if (`menu -query -numberOfItems $parentMenu` == 0)
  42.     {
  43.         menuItem -label "Add Items"
  44.             -command ("lightListEditor -edit -add " + $editorName)
  45.             $addItem;
  46.         menuItem -label "Remove Items"
  47.             -command ("lightListEditor -edit -remove " + $editorName)
  48.             $removeItem;
  49.  
  50.         menuItem -divider true;
  51.  
  52.         menuItem -label "Create Shading Group"
  53.             -command ("sets -renderable 1 -empty")
  54.             $createSGitem;
  55.     }
  56. }
  57.  
  58. global proc buildRRPmodeMenu (string $editorName, string $parentMenu)
  59. {
  60.     setParent -menu $parentMenu;
  61.  
  62.     // These should be unique enough names for the widgets for this
  63.     // instance of the rendering rel. editor
  64.  
  65.     string $lightListsItem         = ($editorName + "lightListsItem");
  66.     string $shadingListsItem    = ($editorName + "shadingListsItem");
  67.  
  68.     // Check to see if we have to build the menu items
  69.  
  70.     if (`menu -query -numberOfItems $parentMenu` == 0)
  71.     {
  72.       radioMenuItemCollection;
  73.         menuItem -label "Lights Lists"
  74.             -radioButton true
  75.             -command ("lightListEditor -edit -mode lightLists " + $editorName)
  76.             $lightListsItem;
  77.         menuItem -label "Shading Lists"
  78.             -radioButton true
  79.             -command ("lightListEditor -edit -mode shadingLists " + $editorName)
  80.             $shadingListsItem;
  81.     }
  82.  
  83.     // Update radio button checks for operating mode
  84.     string $operatingMode = `lightListEditor -query -mode $editorName`;
  85.     menuItem -edit -radioButton ($operatingMode == "lightLists")
  86.       $lightListsItem;
  87.     menuItem -edit -radioButton ($operatingMode == "shadingLists")
  88.       $shadingListsItem;
  89. }
  90.  
  91. global proc buildRRPlistMenu (string $editorName, string $parentMenu)
  92. {
  93.     setParent -menu $parentMenu;
  94.  
  95.     // These should be unique enough names for the widgets for this
  96.     // instance of the rendering rel. editor
  97.  
  98.     string $singleSelectionItem = ($editorName + "singleSelectionItem");
  99.     string $multiSelectionItem    = ($editorName + "multiSelectionItem");
  100.     string $allShadingGroupsItem= ($editorName + "allShadingGroupsItem");
  101.  
  102.     // Check to see if we have to build the menu items
  103.  
  104.     if (`menu -query -numberOfItems $parentMenu` == 0)
  105.     {
  106.       radioMenuItemCollection;
  107.         menuItem -label "Single Selection"
  108.             -radioButton true
  109.             -command ("lightListEditor -edit -singleSelection " + $editorName)
  110.             $singleSelectionItem;
  111.         menuItem -label "Multiple Selection"
  112.             -radioButton true
  113.             -command ("lightListEditor -edit -multipleSelection " + $editorName)
  114.             $multiSelectionItem;
  115.  
  116.         menuItem -divider true;
  117.  
  118.         menuItem -label "All ShadingGroups"
  119.             -checkBox true
  120.             -command ("lightListEditor -edit -allShadingGroups " + $editorName)
  121.             $allShadingGroupsItem;
  122.     }
  123.  
  124.     // Update radio button checks for operating mode
  125.     int $singleSelection = `lightListEditor -query -singleSelection $editorName`;
  126.     int $multiSelection = ! $singleSelection;
  127.  
  128.     menuItem -edit -radioButton $singleSelection $singleSelectionItem;
  129.     menuItem -edit -radioButton $multiSelection $multiSelectionItem;
  130.     
  131.     int $allShadingGroups = `lightListEditor -query -allShadingGroups $editorName`;
  132.     menuItem -edit -checkBox $allShadingGroups $allShadingGroupsItem;
  133. }
  134.  
  135. global proc makeRendRelPanelMenu(string $editorName, 
  136.                                    string $menuBarLayoutName)
  137. {
  138.   setParent $menuBarLayoutName;
  139.  
  140.   // These should be unique enough names for the widgets for this
  141.   // instance of the set editor
  142.  
  143.   string $modeMenu = ($editorName + "modeMenu");
  144.   string $editMenu = ($editorName + "editMenu");
  145.   string $listMenu = ($editorName + "listMenu");
  146.  
  147.   menu -label "Mode" -tearOff true -aob true $modeMenu;
  148.   menu -edit -postMenuCommand ("buildRRPmodeMenu " + $editorName + " " + $modeMenu) $modeMenu;
  149.   setParent -menu ..;
  150.  
  151.   menu -label "Edit" -tearOff true $editMenu;
  152.   menu -edit -postMenuCommand ("buildRRPeditMenu " + $editorName + " " + $editMenu) $editMenu;
  153.   setParent -menu ..;
  154.  
  155.   menu -label "List" -tearOff true $listMenu;
  156.   menu -edit -postMenuCommand ("buildRRPlistMenu " + $editorName + " " + $listMenu) $listMenu;
  157.   setParent -menu ..;
  158. }
  159.  
  160. global proc makeRendRelPanelPopupMenu(string $editorName)
  161. {
  162.   string $menuPopup = ($editorName + "menuPopup");
  163.  
  164.   popupMenu -ctrlModifier false
  165.     -button 3 -aob false -parent $editorName
  166.     $menuPopup;
  167.  
  168.   // These should be unique enough names for the widgets for this
  169.   // instance of the set editor
  170.  
  171.   string $modeMenu = ($editorName + "modePopupMenu");
  172.   string $editMenu = ($editorName + "editPopupMenu");
  173.   string $listMenu = ($editorName + "listPopupMenu");
  174.  
  175.   menuItem -label "Mode" -tearOff true -subMenu true $modeMenu;
  176.   menuItem -edit -postMenuCommand ("buildRRPmodeMenu " + $editorName + " " + $modeMenu) $modeMenu;
  177.   setParent -menu ..;
  178.  
  179.   menuItem -label "Edit" -tearOff true -subMenu true -aob true $editMenu;
  180.   menuItem -edit -postMenuCommand ("buildRRPeditMenu " + $editorName + " " + $editMenu) $editMenu;
  181.   setParent -menu ..;
  182.  
  183.   menuItem -label "List" -tearOff true -subMenu true $listMenu;
  184.   menuItem -edit -postMenuCommand ("buildRRPlistMenu " + $editorName + " " + $listMenu) $listMenu;
  185.   setParent -menu ..;
  186. }
  187.  
  188.  
  189. global proc rendRelPanel(string $panelName) {
  190.     global string $gMainPane;
  191.  
  192.     // instantiate a new rendRelPanel
  193.  
  194.     setParent $gMainPane;
  195.     scriptedPanel -unParent -type rendRelPanel -l $panelName $panelName;
  196. }
  197.  
  198.  
  199.  
  200.  
  201. global proc createRendRelPanel (string $whichPanel)
  202. //
  203. //  Description:
  204. //        Define the editors that are used in this panel.  No
  205. //        controls (widgets) are created at this point.
  206. //
  207. {
  208.     //  create unique names for editors based on panel name
  209.     //
  210.     string $rendRelEd     = ($whichPanel + "RendRelEd");
  211.     string $outlineEd     = ($whichPanel + "OutlineEd");
  212.     
  213.     lightListEditor    -unParent $rendRelEd;
  214.  
  215.     outlinerEditor 
  216.         -unParent
  217.          -mainListConnection worldList
  218.          -selectionConnection modelList
  219.         $outlineEd;
  220. }
  221.  
  222. global proc addRendRelPanel (string $whichPanel)
  223. //
  224. //  Description:
  225. //        Add the panel to a layout.
  226. //        Parent the editors to that layout and create any other
  227. //        controls (widgets) required.
  228. //
  229. {
  230.     string $rendRelEd = ($whichPanel + "RendRelEd");
  231.     string $outlineEd = ($whichPanel + "OutlineEd");
  232.  
  233.     waitCursor -state on;
  234.  
  235.     string $fl = `frameLayout -bv 0 -lv 0 rreFrameLayout`;
  236.     string $pl = `paneLayout -configuration "vertical2" -ps 1 35 100 rrePaneLayout`;
  237.  
  238.     // Parent the editors to the editor layout
  239.     //
  240.     outlinerEditor -edit -parent $pl $outlineEd;
  241.     lightListEditor -edit -parent $pl $rendRelEd;
  242.  
  243.  
  244.  
  245.     // Make the menus
  246.     string $menuBarLayoutName = `scriptedPanel -q -control $whichPanel`;
  247.     string $formLayoutName = `formLayout`;
  248.  
  249.     if (`optionVar -exists showRendRelPanelMenu`) {
  250.       showRendRelPanelMenu 
  251.         (`optionVar -query showRendRelPanelMenu`) $menuBarLayoutName;
  252.     }
  253.     // Attach the menus to the menu form
  254.     makeRendRelPanelMenu $rendRelEd $menuBarLayoutName;
  255.  
  256.  
  257.     // Attach the popup menu to the editor
  258.     makeRendRelPanelPopupMenu $rendRelEd;
  259.  
  260.     setParent -top;
  261.     waitCursor -state off;
  262. }
  263.  
  264. global proc removeRendRelPanel (string $whichPanel)
  265. //
  266. //  Description:
  267. //        Remove the panel from a layout.
  268. //        Delete controls.
  269. //
  270. {
  271.     string $rendRelEd = ($whichPanel + "RendRelEd");
  272.     string $outlineEd = ($whichPanel + "OutlineEd");
  273.  
  274.     if (`outlinerEditor -exists $outlineEd`) {
  275.         outlinerEditor -edit -unParent $outlineEd;
  276.     }
  277.     if (`lightListEditor -exists $rendRelEd`) {
  278.         lightListEditor -edit -unParent $rendRelEd;
  279.     }
  280. }
  281.  
  282. global proc deleteRendRelPanel (string $whichPanel)
  283. //
  284. //  Description:
  285. //        This proc will delete the contents of the panel, but not
  286. //        the panel itself.
  287. //
  288. //  Note:
  289. //        We only need to delete editors here.  Other UI will be taken care of
  290. //        by the remove proc.
  291. //
  292. {
  293.     string $rendRelEd = ($whichPanel + "RendRelEd");
  294.     string $outlineEd = ($whichPanel + "OutlineEd");
  295.  
  296.     if (`lightListEditor -exists $rendRelEd`) {
  297.         deleteUI -editor $rendRelEd;
  298.     }
  299.     if (`outlinerEditor -exists $outlineEd`) {
  300.         deleteUI -editor $outlineEd;
  301.     }
  302. }
  303.  
  304. global proc string saveStateRendRelPanel (string $whichPanel)
  305. //
  306. //  Description:
  307. //        This proc returns a string that when executed will restore the
  308. //        current state of the panel elements.
  309. //
  310. {
  311.     string $indent = "\n\t\t\t";
  312.     string $rendRelEd = ($whichPanel + "RendRelEd");
  313.     string $outlineEd = ($whichPanel + "OutlineEd");
  314.  
  315.     return (
  316.             $indent + "$editorName = ($panelName+\"OutlineEd\");\n" +
  317.             `outlinerEditor -query -stateString $outlineEd` + ";\n" +
  318.             $indent + "$editorName = ($panelName+\"RendRelEd\");\n" +
  319.             `lightListEditor -query -stateString $rendRelEd`
  320.     );
  321. }
  322.  
  323.  
  324. global proc addToRREpanel(string $whichPanel) {
  325.         frameLayout -bv 0 -lv 0 rreFrameLayout;
  326.         paneLayout -configuration "vertical2" -ps 1 35 100 rrePaneLayout;
  327.  
  328.         outlinerEditor -mainListConnection worldList -selectionConnection modelList outEd;
  329.         lightListEditor renderingRelEditor;
  330. }
  331.